<div align="center" id="show" class="ui-widget ui-widget-content ui-corner-all" style="width: 99%; height: 100%;margin: 3px;">
	<div class="ui-widget ui-state-default ui-corner-top ui-title">
		<label>Recibos Emitidos</label>
	</div>
	 <table class="ui-panelLayout-main">
            <tr><td style="vertical-align: top;">
                    <table style="width: 100%;" border="0">
                        <tr>
 <!-- 
 p_ccajero 
 p_dfecpag
 p_nombre  
 p_cnumcom
 <button id="btnbuscar" name="btnbuscar">Buscar</button>
  -->
                            <td width="20px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td width="100px">Fecha</td>
                            <td width="10px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td width="100px">Cajero</td>
                            <td width="10px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td width="400px" ></td>
                            <td width="100%" rowspan="4">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button id="btnbuscar" name="btnbuscar">Buscar</button></td>
                        </tr>
                        <tr id="grouobus1">
                            <td >&nbsp;</td>
                            <td ><input class="ui-text" id="c_fechapag"  style="width:80px" /></td>
                            <td >&nbsp;</td>
                            <td ><input class="ui-text pnl" id="c_codcaj" style="width:100px" maxlength="4"/></td>
                            <td width="10px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td  >&nbsp;</td>
                        </tr>
                        <tr>
                            <td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td >Nro de Recibo </td>
                            <td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td >Cod.Contri</td>
                            <td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
                            <td >Nombre de Contribuyente</td>
                            
                        </tr>
                        <tr id="grouobus2">
                            <td >&nbsp;</td>
                            <td ><input class="ui-text" id="c_numrec" maxlength="12" style="width:100px" /></td>
                            <td >&nbsp;</td>
                            <td ><input class="ui-text pnl" id="c_codcontri"  maxlength="10"style="width:100px" /></td>
                            <td >&nbsp;</td>
                            <td ><input class="ui-text pnl" id="c_nomcontri" style="width:400px" /></td>
                            
                        </tr>
                        <tr>
                            <td colspan="14" height="8px"></td>
                        </tr>
                        <tr>
                            <td colspan="14" align="center" width="100%"> 
                                <br/>
                                <div id="PanellistadeRecibos">
                                    
                                </div>
                            </td>
                        </tr>
                    </table>
                </td></tr>
        </table>
	
</div>
<?php $ddatosuserlog = new Zend_Session_Namespace('datosuserlog'); ?>
<script type="text/javascript">
  
optionRecibos = {
        //height: 140,
        height: 400,
        width: 980,
        //autowidth: true,
        rownumbers: true,
        rowNum: 1000,
        colNames: [
				'cnumope',
				'Nro Recibo',
				'Codigo',
				'Contribuyente',
				'cidpred',
				'ctiping',
				'Concepto',
				'ncantid',
				'cperanio',
				'Fec. Pago',
				'Fec. Pago2',
				'group1',
				'ccajero',
				'usuario', 
				'ctippag',
				'Tipo de Pago', 
				'siglatippag', 
				'nestado', 
				'Estado', 
				'Insoluto',
				'Mont. Reajuste', 
				'Mora', 
				'Cost.Emision', 
				'Total',
				'cidapertura',
				'group2',
				'  '
        ],
        colModel: [
                   {name: 'cnumope', index:'cnumope', width: 80, align: 'left',hidden: true},
                   {name: 'cnumcom', index:'cnumcom', width: 120},
                   {name: 'cidpers', index:'cidpers', width: 62,hidden: true},
                   {name: 'nombre', index:'nombre', width: 200, align:"left",hidden: true},
                   {name: 'cidpred', index:'cidpred', width: 20,hidden: true},
                   {name: 'ctiping', index:'ctiping', width: 20,hidden: true},
                   {name: 'vtiping', index:'vtiping', width: 150},
                   {name: 'ncantid', index:'ncantid', width: 20,hidden: true},
                   {name: 'cperanio', index:'cperanio', width: 20,hidden: true},
                   {name: 'dfecpag', index:'dfecpag', width: 80, align:"right", hidden: true},
                   {name: 'dfecpag', index:'dfecpag2', width: 80, hidden: true},
                   {name: 'group1', index:'group1', width: 100},
                   {name: 'ccajero', index:'ccajero', width: 100,hidden: true},
                   {name: 'usuario', index:'usuario', width: 100,hidden: true},
                   {name: 'ctippag', index:'ctippag', width: 50,hidden: true},
                   {name: 'vtippag', index:'vtippag', width: 120},
                   {name: 'siglatippag', index:'siglatippag', width: 100,hidden: true},
                   {name: 'nestado', index:'nestado', width: 100,hidden: true},
                   {name: 'vestado', index:'vestado', width: 70},
                   {name: 'nimpins', index:'nimpins', width: 70, align:"right", sorttype:"float", formatter:"number"},
                   {name: 'nimprea', index:'nimprea', width: 90, align:"right", sorttype:"float", formatter:"number"},
                   {name: 'nimpmor', index:'nimpmor', width: 70, align:"right", sorttype:"float", formatter:"number"},
                   {name: 'ncosemi', index:'ncosemi', width: 80, align:"right", sorttype:"float", formatter:"number"},
                   {name: 'nmontot', index:'nmontot', width: 70, align:"right", sorttype:"float", formatter:"number", summaryType:'sum'},
                   {name: 'cidapertura', index:'cidapertura', width: 100,hidden: true},
                   {name: 'group2', index:'group2', width: 70},
                   {name: 'imp', index:'imp', width: 20}
               ],
			caption: "&nbsp;&nbsp;&nbsp;Recibos Emitidos",
			grouping: true,
		   	groupingView : {
		   		groupField : ['group1','group2'],
		   		groupColumnShow : [false,false],
		   		groupText : ['<b>{0} - {1} Recibos</b> ', '<b>{0}</b>'],
		   		groupCollapse : true,
				//groupOrder: ['asc','asc'],
				groupSummary : [true,true],
				showSummaryOnHide: true,
				//groupDataSorted : true
		   	}
    };

	listarRecibos = function() {
		parameters = {
			"name": "tblListarRecibos",
			"procedure": "tesoreria.verrecibos",
			"print": "true",
			"parameters": '{' +
			//p_cnumope character varying, p_nombre character varying, p_cnumcom character varying, p_ccajero
			'"p_cnumope":"",' +
			'"p_nombre":"'+$('#c_nomcontri').val()+'",' +
			'"p_cnumcom":"'+$('#c_numrec').val()+'",' +
			'"p_ccajero":"'+$('#c_codcaj').val()+'",' +
			'"p_dfecpag":"'+$('#c_fechapag').val()+'",' +
			'"p_cidpers":"'+$('#c_codcontri').val()+'"' +
			'}'
		};	
		
		procesar = function(requestData){
			options = $.extend(optionRecibos, {
				data: requestData,
				datatype: "local",
				gridComplete: function(){
					isGridComplete = true;
					$("#tblListaRecibos").jqGrid('setSelection', 1, true);
					//jQuery("#tblListaRecibos").jqGrid('navGrid','#tblListaRecibos',{edit:false,add:false,del:false});
					jQuery("#tblListaRecibos").jqGrid('bindKeys', {"onEnter":function( rowid ) { /*alert("You enter a row with id:"+rowid)*/} } );
					//var grid = $("#tblListaRecibos"),
				    //sum = grid.jqGrid('getCol', 'nmontotal', true, 'sum');

					//pie de grilla
					//grid.jqGrid('footerData','set', {ID: 'fnmontotal:', nmontotal: sum});
					//grid.jqGrid('footerData','set', {ID: 'fcnumcom', cnumcom: 'Total',align:"right"});

					var ids = jQuery("#tblListaRecibos").jqGrid('getDataIDs');
					var impritodo ='';
                                        <?php echo "pathReport='".$this->util()->getPathReport()."'; vHostServer='".$this->util()->getHost()."'; P_USER='".$ddatosuserlog->userlogin."' ; " ?>  
                                                
					for(var i=0;i < ids.length;i++){
						var cl = ids[i];
						var rowdat = jQuery("#tblListaRecibos").jqGrid('getRowData',cl);
                                                
                                                buttimp='<div title="Imprimir Recibo Nro. '+rowdat.cnumcom+'" style="float: left; cursor: pointer; display: block;" class="ui-pg-div ui-inline-edit"  onmouseover="jQuery(this).addClass(\'ui-state-hover\');" onmouseout="jQuery(this).removeClass(\'ui-state-hover\')" onclick="imprimirreciboduplicado(\''+rowdat.cnumcom+'\',\''+rowdat.cnumope+'\',\''+rowdat.ctiping+'\',\''+vHostServer+'\');" ><span class="ui-icon ui-icon-print"></span></div>';
						//impritodo +='imprimirreciboduplicado(\''+rowdat.cnumcom+'\' , \''+rowdat.ctiping+'\');';
						
						jQuery("#tblListaRecibos").jqGrid('setRowData',ids[i],{imp:buttimp});
					}
					/*
					$('#btnimpope').click(function(){
							eval(impritodo);
					});
					*/
					
				}
			});
			procesarJSON("PanellistadeRecibos", "tblListaRecibos", optionRecibos, null, null);
		};
		procesarConsultaSubProceso("registrar", parameters, procesar, 'json');
	};

	$(document).ready(function(){
		//listarRecibos();
		//inicializarGrid("tblListaRecibos", optionRecibos);
		$("#btnbuscar").button("option", "icons", {
	        primary:'ui-icon-search'
	   });
		$("#btnbuscar").click(function(){
			listarRecibos();});
		});	
	 	
	 
	 $("#grouobus1").on("keyup", "input", function(e) {
	        if(e.keyCode == 13){
	            $("#btnbuscar").click();
	        }
	    });
	 $("#grouobus2").on("keyup", "input", function(e) {
	        if(e.keyCode == 13){
	            $("#btnbuscar").click();
	        }
	    });   
	 $("#c_fechapag").datepicker({
			dateFormat : "yy-mm-dd",
			changeMonth:true,
			changeYear:true,
			showOn: "button",
			buttonImage:  "<?php  echo $this->util()->getImage('calendar.gif'); ?>", buttonImageOnly: true
		});
	$("#c_codcaj").focus();
</script>

